import request from "@/utils/request";
import axios from "axios";
import { EquipmentInfo,AnnouncementInfo,UserManagementInfo } from "./model";
const equipmentUrl="/logistics/equipment"
const announcementUrl="/logistics/announcements"
const userManagementUrl="/logistics/userManagement"
class LogisticsApi {
  /**
   * 获取设备表信息
   */
  static getEquipments() {
    return request<any, EquipmentInfo[]>({
      url: equipmentUrl+"/queryAll",
      method: "get"
    })
  }

  /**
   * 添加设备表信息
   */
  static insertEquipment(data:EquipmentInfo) {
    return request<any, EquipmentInfo>({
      url: equipmentUrl+"/insert",
      params: <EquipmentInfo>{
        id: data.id,
        name: data.name,
        location: data.location,
        status: data.status,
        createdAt: data.createdAt
      },
      method: "get"
    });
  }

  /**
   * 删除设备表信息
   */
  static deleteEquipment(id:EquipmentInfo) {
    return request<any, EquipmentInfo>({
      url: equipmentUrl+"/deleteById",
      params: <EquipmentInfo>{
        id: id,
      },
      method: "get"
    });
  }

  /**
   * 更新设备表信息
   */
  static updateEquipment(data:EquipmentInfo) {
    return request<any, EquipmentInfo>({
      url: equipmentUrl+"/update",
      params: <EquipmentInfo>{
        id: data.id,
        name: data.name,
        location: data.location,
        status: data.status,
        createdAt: data.createdAt
      },
      method: "get"
    });
  }

//   =================公告=============

  /**
   * 获取公告表信息
   */
  static getAnnouncements() {
    return request<any, AnnouncementInfo[]>({
      url: announcementUrl+"/queryAll",
      method: "get"
    })
  }

  /**
   * 添加公告表信息
   */
  static insertAnnouncement(data:AnnouncementInfo) {
    return request<any, AnnouncementInfo>({
      url: announcementUrl+"/insert",
      params: <AnnouncementInfo>{
        id: data.id,
        title: data.title,
        category: data.category,
        content: data.content,
        createdAt: data.createdAt
      },
      method: "get"
    });
  }

  /**
   * 删除公告表信息
   */
  static deleteAnnouncement(id:number) {
    return request<any, AnnouncementInfo>({
      url: announcementUrl+"/deleteById",
      params: <number>{
        id: id,
      },
      method: "get"
    });
  }

  /**
   * 更新公告表信息
   */
  static updateAnnouncement(data:AnnouncementInfo) {
    return request<any, AnnouncementInfo>({
      url: announcementUrl+"/update",
      params: <AnnouncementInfo>{
        id: data.id,
        title: data.title,
        category: data.category,
        content: data.content,
        createdAt: data.createdAt
      },
      method: "get"
    });
  }
//   =================用户管理=============

  /**
   * 获取用户表信息
   */
  static getUserManagements() {
    return request<any, UserManagementInfo[]>({
      url: userManagementUrl+"/getTableData",
      method: "get"
    })
  }

  /**
   * 添加用户表信息
   */
  static insertUserManagement(data:UserManagementInfo) {
    return request<any, UserManagementInfo>({
      url: userManagementUrl+"/insert",
      params: <UserManagementInfo>{
        id: data.id,
        userName: data.userName,
        blacklist: data.blacklist,
        blacklistDays: data.blacklistDays,
      },
      method: "get"
    });
  }

  /**
   * 删除用户表信息
   */
  static deleteUserManagement(id:number) {
    return request<any, UserManagementInfo>({
      url: userManagementUrl+"/deleteById",
      params: <number>{
        id: id,
      },
      method: "get"
    });
  }

  /**
   * 更新用户表信息
   */
  static updateUserManagement(data:UserManagementInfo) {
    return request<any, UserManagementInfo>({
      url: userManagementUrl+"/update",
      params: <UserManagementInfo>{
        id: data.id,
        userName: data.userName,
        blacklist: data.blacklist,
        blacklistDays: data.blacklistDays,
      },
      method: "get"
    });
  }
}

export default LogisticsApi;
